From 15347ebb357fe587c2f9e55bdeb5ef6af36b7958 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 31 Jan 2014 15:07:55 +0000 Subject: [PATCH] libxl: timeouts: Record deregistration when one occurs When a timeout has occurred, it is deregistered. However, we failed to record this fact by updating etime->func. As a result, libxl__ev_time_isregistered would say `true' for a timeout which has already happened. It is necessary to clear etime->func before the callback, because the callback might want to reinstate the timeout, or might free the etime (or its containing struct) entirely. The results are that we might try to have the timeout occur again (causing problems for the call site), and/or corrupt the timeout list. This fixes the timedereg event system unit test. Signed-off-by: Ian Jackson Cc: Jim Fehlig Cc: Ian Campbell Acked-by: Ian Campbell --- tools/libxl/libxl_event.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 5a99932d96..ea8c744461 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -387,7 +387,9 @@ static void time_occurs(libxl__egc *egc, libxl__ev_time *etime) etime, (unsigned long)etime->abs.tv_sec, (unsigned long)etime->abs.tv_usec); - etime->func(egc, etime, &etime->abs); + libxl__ev_time_callback *func = etime->func; + etime->func = 0; + func(egc, etime, &etime->abs); } -- 2.30.2